// 当返回的是这种格式时 {“responseCode”: 0, “message”: “”, “entry”: []}
import 'EntityFactory.dart';

class BaseListEntity<T> {
  String? responseCode;
  String? message;
  List<T> entry;

  BaseListEntity({this.responseCode, this.message, required this.entry});

  factory BaseListEntity.fromJson(json) {
    List<T> mData = [];
    if (json['entry'] != null) {
      //遍历entry并转换为我们传进来的类型
      (json['entry'] as List).forEach((v) {
        mData.add(EntityFactory.generateOBJ<T>(v) as T);
      });
    }

    return BaseListEntity(
      responseCode: json["responseCode"].toString(),
      message: json["message"],
      entry: mData,
    );
  }
}
